<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="utf-8">
  <title>详情</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" th:href="@{/layui/css/layui.css}" media="all">
  <link rel="stylesheet" th:href="@{/style/custom.css}" media="all">
</head>
<body>

<div class="layui-tab">
  <input type="hidden" id="processInstId" name="processInstId" th:value="${processInstId}">
  <ul class="layui-tab-title">
    <li class="layui-this">流程图</li>
  </ul>
  <div class="layui-tab-content">
    <div class="layui-tab-item layui-show">
      <img id="instImg" src="" />
    </div>
  </div>
</div>

<script th:src="@{/layui/layui.js}"></script>
<script>
  layui.config({
    base: '/'
  }).extend({
    //设定模块别名，模块名是使用layui.模块名  模块文件是 js名字。不设置模块名 = 模块文件名
    flying: 'flying'
  }).use(['index', 'flying'], function(){
    const $ = layui.$
        ,admin = layui.admin
        ,form = layui.form
        ,table = layui.table
        ,layer = layui.layer
        ,dropdown = layui.dropdown
        ,flying = layui.flying;

    let loadIndex = layer.load(0);
    let windowUrl = window.URL || window.webkitURL;//处理浏览器兼容性
    let xhr = new XMLHttpRequest();
    xhr.open("GET", '/flow/instance/process/image?processInstId=' + layui.$("#processInstId").val(), true);
    xhr.responseType = "blob";
    xhr.onload = function () {
      if (this.status == 200) {
        let blob = this.response;
        let imgUrl = windowUrl.createObjectURL(blob);
        document.getElementById('instImg').src = imgUrl;
        layer.close(loadIndex)
        // URL.revokeObjectURL(imgUrl);
      }
    }
    xhr.send();

  });
</script>
</body>
</html>
